<?
	require_once "../../_func/__Global.php";
	require_once "../../_func/__Local.php";
	require_once "../../_func/__MysqlFunc.php";
	require_once "../../_func/_CodeFunc.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>:: 농협전북지부 ERP시스템 ::</title>
<link href="../css/layout.css" type="text/css" rel="stylesheet" />
<link type="text/css" href="/css/hot-sneaks/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.18.custom.min.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript">
$(function(){
	// Datepicker
	var chk1=0;
	$('#t_product_date').datepicker({
		inline: true,
		showOn: 'button',
		buttonImage:"/img/ico_cal.jpg",
		buttonImageOnly: true
	});
	//hover states on the static widgets
	$('#dialog_link, ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); },
		function() { $(this).removeClass('ui-state-hover'); }
	);

	$('#order_arrivaldate').datepicker({
		inline: true,
		showOn: 'button',
		buttonImage:"/img/ico_cal.jpg",
		buttonImageOnly: true
	});
});
</script>
<script type="text/javascript">
	function value_check()
	{
		if (!isEmpty($('#t_product_date')))
		{
			alert("등록일을 입력하세요");
			$('#t_product_date').focus();
			return;
		}
		if (!isEmpty($('#jbnh_seq')))
		{
			alert("농협을 선택하세요");
			$('#jbnh_seq').focus();
			return;
		}
		if (!isEmpty($('#farm_seq')))
		{
			alert("생산자명을 선택하세요");
			$('#farm_seq').focus();
			return;
		}
		if (!isEmpty($('#t_product_item1')))
		{
			alert("품목을 선택하세요");
			$('#t_product_item1').focus();
			return;
		}
		if (!isEmpty($('#t_product_item2')))
		{
			alert("품종을 선택하세요");
			$('#t_product_item2').focus();
			return;
		}
		if ($("#t_product_workyn").val()=="Y" && !isEmpty($('#product_grade2')))
		{
			alert("등급을 선택하세요");
			$('#product_grade2').focus();
			return;
		}
		if ($("#t_product_workyn").val()=="Y" && !isEmpty($('#product_standard2')))
		{
			alert("규격을 선택하세요");
			$('#product_standard2').focus();
			return;
		}
		if (!isEmpty($('#t_product_weight2')))
		{
			alert("중량 선택하세요");
			$('#t_product_weight2').focus();
			return;
		}
		if (!isEmpty($('#product_number')))
		{
			alert("수량을 입력하세요");
			$('#product_number').focus();
			return;
		}
		if (!isNumber($('#product_number')))
		{
			alert("수량은 숫자만 입력하세요");
			$('#product_number').val("");
			$('#product_number').focus();
			return;
		}
		if ($('#product_number').val()<=0)
		{
			alert("수량은 0보다 큰수를 입력하세요");
			$('#product_number').val("");
			$('#product_number').focus();
			return;
		}
		document.theForm.target="if_nvl";
		document.theForm.submit();
	}
	function totalinput()
	{
		if ($('#product_number').val()!="" && !isNumber($('#product_number')))
		{
			alert("수량은 숫자만 입력하세요");
			$('#product_number').val("");
			$('#product_number').focus();
			return;
		}
		if ($('#t_product_weight2').val()!="")
		{
			var inisum = $('#t_product_weight2').val()*$('#product_number').val();
			var html = $("#sum").html();
			html = inisum +"KG";
			$("#sum").html(html);
			$("#t_product_total").val(inisum);
			return;
		}
	}
	function totalinput2()
	{
		if ($('#product_number').val()!="" && isNumber($('#product_number')) && $('#t_product_weight2').val()!="")
		{
			var inisum = $('#t_product_weight2').val()*$('#product_number').val();
			var html = $("#sum").html();
			html = inisum +"KG";
			$("#sum").html(html);
			$("#t_product_total").val(inisum);
			return;
		}
	}
	function fnview(seq)
	{
		location="item_manage_in.html?menu1=<?=$menu1?>&menu2=<?=$menu2?>&seq="+seq;
	}
	function cancle_check()
	{
		location="item_manage_in.html?menu1=<?=$menu1?>&menu2=<?=$menu2?>";
	}
	function input_check()
	{
		document.theForm.mode.value="w";
		value_check();
	}
	function update_check()
	{
		document.theForm.mode.value="u";
		value_check();
	}
	function delete_check()
	{
		if(confirm("삭제하시겠습니까?"))
		{
			document.theForm.mode.value="d";
			document.theForm.target="if_nvl";
			document.theForm.submit();
		}
	}
	function fnlist()
	{
		location="item_manage_in.html?menu1=<?=$menu1?>&menu2=<?=$menu2?>";
	}
	function fnWork()
	{
		if ($("#t_product_workyn").val()=="N")
		{
			$('#product_grade2').attr('disabled',"disabled");
			$('#product_standard2').attr('disabled',"disabled");
		}
		else
		{
			$('#product_grade2').removeAttr("disabled");
			$('#product_standard2').removeAttr("disabled");
		}
	}
	$(document).ready(function(){
		if ($("#t_product_item1").val()!="")
		{
			fncGetItemJSON('item', 2, $("#t_product_item1").val(), $('#t_product_item2'));
			totalinput2();
		}
		if ($("#jbnh_seq").val()!="")
		{
			fncGetFarmJSON('nfitem', $("#jbnh_seq").val(), $('#farm_seq'));
		}
		if ($("#t_product_workyn").val()=="N")
		{
			$('#product_grade2').attr('disabled',"disabled");
			$('#product_standard2').attr('disabled',"disabled");
		}
		else
		{
			$('#product_grade2').removeAttr("disabled");
			$('#product_standard2').removeAttr("disabled");
		}
	});
</script>
</head>

<body>
<div id="wrap">
<!-- header start -->
<? include("../_layout/head.inc"); ?>
<!-- header end -->

<!-- view start -->
<? include("./item_manage_edit.php"); ?>
<!-- view end -->

<!-- container start -->
	<div id="container">
    	<div class="subtit">
        	<p class="subtt02"><span>품목관리 > 입고관리</span></p>
		</div>
        <div class="contents">
        	<p class="tableTitle"><span class="b"></span>입고등록</p>
			<form name="theForm" method="post" action="./item_manage_in_proc.php">
			<input type="hidden" name="mode" id="mode" />
			<input type="hidden" name="menu1" id="menu1" value="<?=$menu1?>" />
			<input type="hidden" name="menu2" id="menu2" value="<?=$menu2?>" />
			<input type="hidden" name="seq" id="seq" value="<?=$seq?>" />
        	<table cellpadding="0" cellspacing="1" border="0" class="erpTable td6">
            	<tr>
                	<th>입고일</th>
                    <th>농협명</th>
                    <th>생산자</th>
                    <th>원산지</th>
                    <th>품목</th>
					<th>품종</th>
				</tr>
				<tr>
					<td>
                    	<input type="text" id="t_product_date" value="<?=$ndate?>" name="t_product_date" title="등록일입력/달력을클릭해주세요." readonly class="boxinput w65" style="margin-right:2px;vertical-align:top;" />
					</td>
                    <td>
                    	<select	name="jbnh_seq" id="jbnh_seq" onchange="fncGetFarmJSON('nfitem', this.value, $('#farm_seq'));">
							<option value="">농협명</option>
							<?
								$codedata = & JBNH_GetSelect(0);
								JBNH_PrintOption($codedata, $jseq);
							?>
                        </select>
                    </td>
                     <td>
						 <!--select name="farm_seq" id="farm_seq" onchange="fncGetItemJSON('fitem', 1, this.value, $('#t_product_item1'));"-->
                    	<select name="farm_seq" id="farm_seq">
                        	<option>생산자명</option>
                        </select>
						<input type="hidden" name="fseq" id="fseq" value="<?=$fseq?>" />
                    </td>
                     <td>
                    	<input type="text" name="t_product_country" id="t_product_country" value="<?=$ocountry?>" class="boxinput w50" />
                    </td>
                     <td>
                    	<select name="t_product_item1" id="t_product_item1" onchange="fncGetItemJSON('item', 2, this.value, $('#t_product_item2'));">
                        	<option value="">품목</option>
							<?
								$codedata = & Code_GetSelect("A", 1, 0,false);
								Code_PrintOption($codedata, 1, $oitem1);
							?>
                        </select>
						<input type="hidden" name="oitem2" id="oitem2" value="<?=$oitem2?>" />
                    </td>
					<td>
                    	<select name="t_product_item2" id="t_product_item2">
                        	<option value="">품종</option>
                        </select>
                    </td>

				</tr>
				<tr>
                    <th>선별여부</th>
					<th>등급</th>
					<th>규격</th>
                    <th>중량(kg)</th>
                    <th>수량</th>
					<th>합계</th>
				</tr>
                <tr>
                     <td>
						<?if ($seq==""){?>
							<select name="t_product_workyn" id="t_product_workyn" onchange="fnWork();">
								<option value="Y" <?=($owork=="Y")?"selected":""?>>유</option>
								<option value="N" <?=($owork=="N")?"selected":""?>>무</option>
							</select>
						<?}else{?>
							<?if ($owork=="N"){?>
								<select name="t_product_workyn" id="t_product_workyn" onchange="fnWork();">
									<option value="Y" <?=($owork=="Y")?"selected":""?>>유</option>
									<option value="N" <?=($owork=="N")?"selected":""?>>무</option>
								</select>
							<?}else{?>
								유
							<?}?>
						<?}?>
                    </td>
                    <td>
						<input type="hidden" name="product_grade1" id="product_grade1" value="2" />
                    	<select name="product_grade2" id="product_grade2">
                        	<option value="">등급</option>
							<?
								$codedata = & Code_GetSelect("B", 2, 2,false);
								Code_PrintOption($codedata, 2, $ograde2);
							?>
                        </select>
                    </td>
					<td>
						<input type="hidden" name="product_standard1" id="product_standard1" value="3" />
                    	<select name="product_standard2" id="product_standard2">
                        	<option value="">규격</option>
							<?
								$codedata = & Code_GetSelect("B", 2, 3,false);
								Code_PrintOption($codedata, 2, $ostandard2);
							?>
                        </select>
                    </td>
					<td>
						<input type="hidden" name="t_product_weight1" id="t_product_weight1" value="1" />
                    	<select name="t_product_weight2" id="t_product_weight2" onchange="totalinput2();">
                        	<option value="">중량</option>
							<?
								$codedata = & Code_GetSelect("B", 2, 1,false);
								Code_PrintOption($codedata, 2, $oweight2, "KG");
							?>
                        </select>
                    </td>
					<td><input type="text" id="product_number" name="product_number" onblur="totalinput();" value="<?=$onumber?>" title="수량입력" class="boxinput w50" /></td>
					<td><span id="sum"></span></td>
                </tr>
            </table>
            <div class="BtnList">
            	<ul>
				<?if ($seq==""){?>
                  	<li><input type="button" class="btn_submit" title="등록" onclick="input_check();" /></li>
				<?}else{?>
					<li><input type="button" class="btn_modify" title="수정" onclick="update_check();"/></li>
                    <li><input type="button" class="btn_del" title="삭제" onclick="delete_check();"/></li>
					<li><input type="button" class="btn_cancel" title="취소" onclick="cancle_check();"/></li>
				<?}?>
                </ul>
            </div>
            <input type="hidden" name="t_product_total" id="t_product_total" value="<?=$ototal?>" />
            </form>
            <p class="tableTitle"><span class="b"></span>입고내역 <span style="font-size:12px;color:blue;"> * 최근 7일이내의 입고내역만 출력됩니다.</span></p>
            </p>
			<div class="listframe">
				<table cellpadding="0" cellspacing="1" border="0" class="erpTable">
				<colgroup>
					<col width="3%" />
				</colgroup>
					<tr>
						<th></th>
						<th>입고일자</th>
						<th>농협명</th>
						<th>생산자</th>
						<th>원산지</th>
						<th>품목</th>
						<th>품종</th>
						<th>선별여부</th>
						<th>등급</th>
						<th>규격</th>
						<th>중량</th>
						<th>수량</th>
						<th>합계</th>
						<th>입고확인증</th>
					</tr>
<!-- list start -->
<? include("./item_manage_list.php"); ?>
<!-- list end -->
				</table>
			</div>
        </div>
    </div>
<!-- footer start -->
<? include("../_layout/footer.inc"); ?>
<!-- footer end -->
<iframe name=if_nvl id=if_nvl src='' style='display:none'></iframe>
</div>
</body>
</html>